<template>
  <UiTab>
    <UiTabItem v-for="(item,index) in rows" :key="index" :active="Number(bbs_id) === Number(item.id)"
               @click="handleClick(item.id)">{{ item.title }}
    </UiTabItem>
  </UiTab>
</template>

<script setup>
const route = useRoute()

const {data} = await useBbsListApi()

// 当前社区分类ID
const bbs_id = ref(route.params.bbs_id)

const rows = computed(() => {
  return [{id: 0, title: "全部"}, ...(data.value ? data.value.rows : [])]
})

console.log(rows.value)

// 切换社区分类
function handleClick(id) {
  navigateTo({
    params: {
      ...route.params,
      bbs_id: id,
      page: 1
    },
    query: {
      ...route.query
    }
  })
}

</script>


<style scoped>

</style>
